<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class ExampleController extends Controller
{
  /**
   * Create a new controller instance.
   *
   * @return void
   */
  public function __construct()
  {
  }

  //
  public function index(Request $request)
  {
      return ["0","1"];
//      Log::channel('customLog')->info('MQTT消息:' . json_encode(['r'=>$request->all(), 's'=>$_SERVER]));
//      return ApiReturn(RETURN_SUCCESS, "SUCCESS", $request->all());
        $config = [
            "mqttConfig"    =>  [
                'qos'   =>  0,
                'dataTopicUrl'  =>  'tcp://127.0.0.1:1883',
                'dataTopicName' =>  'KprCJDataUploadTopic',
                'dataTopicUserName' =>  '',
                'dataTopicUserPwd' =>  '',

                'heartTopicUrl'  =>  'tcp://127.0.0.1:1883',
                'heartTopicName' =>  'KprCJHeartTopic',
                'heartTopicUserName' =>  '',
                'heartTopicUserPwd' =>  '',

                'instructTopicUrl'  =>  'tcp://127.0.0.1:1883',
                'instructTopicName' =>  'KprCJInstructTopic',
                'instructTopicUserName' =>  '',
                'instructTopicUserPwd' =>  '',

                'exceptionTopicUrl'  =>  'tcp://127.0.0.1:1883',
                'exceptionTopicName' =>  'KprCJExceptionTopic',
                'exceptionTopicUserName' =>  '',
                'exceptionTopicUserPwd' =>  '',
            ],
            "redisConfig"   =>  [
                "redisUrl"  =>  "127.0.0.1",
                "port"      =>  6379,
                "pwd"       =>  "123456",
                "dataIndex" =>  0,
                "dataListName"  =>  "DataUploadPass",
                "heartListName"  =>  "HeartManagePass",
                "controlListName"  =>  "ControlPass",
                "exceptionListName"  =>  "ExceptionPass",
            ],
            "systemConfig"  =>  [
                "clientId"  =>  md5("PQS"),
                "clientType"    =>  ["0"],
                "heartbeatCycle"    =>  600,
                "ik"    =>  'a3e50a6db5'
            ]
        ];
        $config = "afc57153318ea0efb351208b86155971182c68ac4cf97916fd4aad404fcbc04d338e871ab385063bcf63f8f5b148b31ac51430e32de85dce539c5ffb2c2fbf0c1a0668ff5d5fd800d989aa4112bfe165444f2e11b2ffbdc0840a44ed854aa6be2730143cd61cb9242936c93e459e0722cb1f23a69dbfd2c0fa276cfdb5006e1168e833dd906981d917f672095a09c0e3ca4aee42d09798647dc82dd92ec321035285484171eb6cbadca230c76015330dca2a83e54f7edb2a1c49dfb63884ac64a9a3d3fecde2425419a3a9a3d2dd68ce2f9cf1d299e91a68a394da00808db496b957675feaf7f530003f305fdc943ca54a1a27b1515233f7598a9a66361c2ffd35ac6a71d916039f6b5d519e01bd44df5eaeb45ee0334134e29a6bfa0081bf5ee36018cac3ab7957c4222af2e1b94d211ee4f5dc4cad2c8a852e980d222938ee301667e0790dc4967eddfcdc90ea20f93d8c88c912124c4be6fdec36cd1e4bccf7bb3d581a1db34ddb929f505f43a126f14fd9b6faad4664729edcbde8ef09547a93f54a1b63b5c97d0a169dac7d3be4549c8e77be8a986566e07f46d0d6d9201e3686ca4553ca9eb53076feec3d45ffb9f361d9f063bb3b7de60acce9e9fd2de7c91c261134d1733a58e30abd9c007cc03ee863b7b2bbf65f5599bbf88f65d12c5a2f693c5d86f6dbcbfb220012f89d40a0f219eeebb9835e5e76b93708764528d61244456ae2a7e9271cbf6972f27d823fd7524eba65d11fadfb6e3adb671f52cec5da2c9d418c1ca9c6bf69f89818154bf45dc24b9cd200454ca449f271b432f7eda1fbe751e21e91287d2850e5c68a64ca2a054275eaae2a0bc651586665daf9e6ecaa99d6f3d31976e5e4a91b434b24bf77a0b384d286e9666829911ffa9fc5e87fe4eea103e8d5c5ded84e0e70f20411fab0bf2662ce8199127d701c0c681ba9c0f62e016f541c70d31f45e78adee59fe85367dd83efa31288757881afcdfd90b995f65ce966b972b13ff3b79b42dc0fdc8532c2dcfcfa247b3be04c337c6a467d3f44d20b49e4976f1cf929b651834014883513f85d894b60124abc3bcaaa491a1db8438bed0d96cbdf90213ebc2f9c084c0eb1c9533e556f93bd4e96d302aa93d9d7eab4db1d4883950a38981e355a7e3e084e534ead72d4335409db717497674089aca235204496ed18638fd9d8b000b399395b6c404cddd025c59441e90f1ac2795ded7f479b6bf8e7192e26fc05d9235d9d63a6d720a760a3c031";
//        return $config;
        return ["status"=>0, "msg"=>"SUCCESS", "data"=>['ik'=>'test123321', 'config'=>$config]];
  }

  public function test(Request $request)
  {
//      Log::channel('customLog')->error('This is custom log error.');
      return ApiReturn(RETURN_SUCCESS, "SUCCESS", ['params'=>$request->all(), 'files'=>$_FILES]);
  }

    /**
     * 验签测试接口
     * @param Request $request
     * @return false|string
     * @throws \Exception
     */
  public function checkSign(Request $request) {
      return ApiReturn(RETURN_SUCCESS, '验签成功', $request->all());
  }
}
